package risk.control.project.api;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.core.io.Resource;
import org.springframework.core.io.UrlResource;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import risk.control.project.service.AuthCodeService;
import risk.control.project.service.TakeRecordService;
import risk.control.project.utils.response.ResponseUtils;

import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.Callable;
import java.util.concurrent.CompletableFuture;

import static risk.control.project.utils.vaild.DateTimeValidator.isValidDateTime;
import static risk.control.project.utils.vaild.DateTimeValidator.isValidTimeRange;


@RestController
public class Test {
    private static final Logger logger = LoggerFactory.getLogger(Test.class);

    private final TakeRecordService takeRecordService;

    public Test(TakeRecordService takeRecordService) {
        this.takeRecordService = takeRecordService;
    }

    //导出取现记录
    @GetMapping("main/test")
    public Callable<String> downloadFile(@RequestParam Map<String, String> params) {

        return () -> {
            // 1. 立即返回的提示（客户端会立刻收到这个响应）
            String immediateResponse = "请求已接收，正在后台处理数据: " + "1111";

            // 2. 异步调用（后台继续执行）
            CompletableFuture<String> future = takeRecordService.test();

            // 3. 阻塞等待异步结果（可选，如果不需要结果可省略）
            String asyncResult = future.get();

            return immediateResponse + " | 后台处理结果: " + asyncResult;
        };
    }


}
